package com.example.crawler.config;

import io.swagger.annotations.Api;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

/**
 * FileName:  MySwagger2Config
 * Author:    REZ_VK
 * Date  :   2019-5-18 11:31
 * info :    这个是..
 */

@Configuration
public class MySwagger2Config {
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.example.crawler"))
                .paths(PathSelectors.any())
                .build();
    }
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("SpringBoot利用swagger2构建api文档")
                .description("简单优雅的restfun风格，http://localhost:8080/swagger-ui.html")
                .termsOfServiceUrl("http://localhost:8080/druid/index.html")
                .version("1.0")
                .build();
    }
}
